package 剑指offer;

/**
 * @description:
 * @author: ywk
 * @date: 2021-04-01
 */
public class 缺失数字 {
    public static int solve (int[] a) {
        // write code here
        boolean[] exist = new boolean[a.length+1];
        for (int i = 0; i < a.length; i++) {
            exist[a[i]] = true;
        }
        for (int i = 0; i < exist.length; i++) {
            if (exist[i] == false) {
                return i;
            }
        }
        return 0;
    }

    public static void main(String[] args) {
        System.out.println(solve(new int[]{0, 1, 2, 3, 4, 5, 7}));

    }
}
